﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SmartRFIDSystem19.dao
{
    public class Connection
    {
        //数据库在云端（阿里云-杭州) ，以下数据不用改成本地的  Navicat也可正常管理
        static string server = "120.27.142.116";                  //云端数据库地址
        static string id = "smartrfidsystem";                     //数据库账号
        static string password = "T7HwSAdBP5wCFCsz";             //数据库密码
        static string database = "smartrfidsystem";                //数据库名称
        public static MySqlCommand comm = null;
        public static MySqlConnection conn = null;
        public static string M_str_sqlcon = "server=" + server + ";user id=" + id + ";password=" + password + ";database=" + database;
        public static bool Connect()
        {
            try
            {
                conn = new MySqlConnection(M_str_sqlcon);
                conn.Open();
                // MessageBox.Show("成功");
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败", ex.ToString());
                return false;
            }
        }
    }
}
